<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>查看匠人信息</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        th{
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="ibox-title">
        <h5>查看匠人信息</h5>
    </div>
    <form class="form-horizontal m-t" id="signupForm" action="{:url('getChoose')}" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-1 control-label">茶类</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teacase" style="font-size: 12px;">
                    <option value="{$current['id']}">{$current['teaname']}</option>
                    <option value="10000">查看全部</option>
                    {foreach $teacase as $case}
                    <option value="{$case['id']}">{$case['teaname']}</option>
                    {/foreach}
                </select>
            </div>

            <label class="col-sm-1 control-label">产区</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teaarea" style="font-size: 12px;">
                    {foreach $teaarea as $area}
                    <option value="{$area['id']}">{$area['area']}</option>
                    {/foreach}
                </select>
            </div>
            <div class="col-sm-2">
                <button class="btn btn-primary" type="submit">提交</button>
            </div>
        </div>
    </form>

    <div class="form-group">

    </div>

    <div class="form-horizontal m-t">
    <div class="form-group">
        <label class="col-sm-1 control-label">显示</label>
        <div class="col-sm-4">
            <label class="checkbox-inline">
                <input type="checkbox" class="contact" id="inlineCheckbox6" checked>茶类</label>
            <label class="checkbox-inline">
                <input type="checkbox" class="contact" id="inlineCheckbox7" checked>产地</label>
            <label class="checkbox-inline">
                <input type="checkbox" class="phone" id="inlineCheckbox2" checked>电话</label>
            <label class="checkbox-inline">
                <input type="checkbox" class="wechat" id="inlineCheckbox3" checked>微信</label>
            <label class="checkbox-inline">
                <input type="checkbox" class="briefintro" id="inlineCheckbox4">简介</label>
            <label class="checkbox-inline">
                <input type="checkbox" class="detailintro" id="inlineCheckbox5">详情</label>
        </div>


    <div class="ibox-content">
        <table class="table table-striped">
        <!-- table -->
            <thead>
                <tr>
                    <th class='case'>茶类</th>
                    <th class='area'>产地</th>
                    <th>匠人姓名</th>
                    <th>匠心指数</th>
                    <th class='contact'>联系人</th>
                    <th class='phone'>电话</th>
                    <th class='wechat'>微信</th>
                    <th class='briefintro' ></th>
                    <th class='detailintro' ></th>
                    <th>修改</th>
                    <th>删除</th>
                </tr>
            </thead>

            <tbody>
                <!-- <tr>
                    <td>1</td>
                    <td><span>张三</span></td>
                    <td>90</td>
                    <td>国家级非物质文化遗产“武夷岩茶（大红袍）制作技艺”代表性传承人，制茶工程师，制茶工艺师。</td>
                    <td>乌龙茶</td>
                    <td>武夷岩茶</td>
                    <td>李四</td>
                    <td>13612345678</td>
                    <td>13612345678</td>
                    <td >
                        <button type="button"  data-toggle="modal" data-target="#myModal">
                          查看
                        </button>
                    </td>
                    <td><button>修改</button></td>
                    <td><button>删除</button></td>
                </tr> -->
                {foreach $data as $onedata}
                <tr index = "{$onedata['id']}">
                    <td >
                        <select class="form-control m-b" name="chooseteacase" style="font-size: 12px;width: 90px;">
                            <option value="{$current['id']}">{$current['teaname']}</option>
                            {foreach $teacase as $case}
                            <option value="{$case['id']}">{$case['teaname']}</option>
                            {/foreach}
                        </select>
                    </td >

                    <td >
                        <select class="form-control m-b" name="chooseteaarea" style="font-size: 12px;">
                            <option value="{$currentArea['id']}">{$currentArea['area']}</option>
                            {foreach $teaarea as $area}
                            <option value="{$area['id']}">{$area['area']}</option>
                            {/foreach}
                        </select>
                    </td >

                    <td >
                        <input index="{$onedata['id']} type="text" name="name" value="{$onedata['name']}" style="width: 80px;text-align: center;border: none;">
                    </td >

                    <td >
                        <input type="text" name="score" value="{$onedata['score']}" style="width: 80px;text-align: center;border: none;">
                    </td>

                    <td >
                        <input type="text" name="contact" value="{$onedata['contact']}" style="width: 80px;text-align: center;border: none;">
                    </td>

                    <td >
                        <input type="text" name="phone" value="{$onedata['phone']}" style="width: 120px;text-align: center;border: none;">
                    </td>

                    <td >
                        <input type="text" name="wechat" value="{$onedata['wechat']}" style="width: 200px;text-align: center;border: none;">
                    </td>

                    <td >
                        <textarea cols="20" rows="6" name="briefintro" style="border: none;display: none;" >{$onedata['briefintro']}</textarea>
                    </td>

                    <td >
                        <textarea cols="50" rows="6" name="detailintro" style="border: none;display: none;">{$onedata['detailintro']}</textarea>
                    </td>

                    <td >
                        <button class="modify" index="{$onedata['id']}">修改</button>
                    </td>

                    <td >
                        <button class="del" del="{$onedata['id']}" data-toggle="modal"  data-target="#delmod">删除</button>

                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>

    <!-- 删除提示Modal -->
    <div class="modal fade" id="delmod" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">确定要删除吗？</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="id" class="delID">
                    <p>删除后将不可恢复！！！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-default confirmDel" data-dismiss="modal" >删除</button>
                </div>
            </div>
        </div>
    </div>



<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="__STATIC__/js/index.js"></script>
<script type="text/javascript">

    //删除
    $(".del").click(function(){
        var id = $(this).attr("del");
        $("input.delID").val(id);
    })

    //确认删除
    $("button.confirmDel").click(function(){
        var delID = $("input.delID").val();
        var url = "{:url('delJr')}";
        var data = {id:delID};
        $.post(url, data, function(data){
            if(data==1){
                $("tr[index="+delID+"]").remove();
                alert("删除成功");
            }
        });

    })


    //修改
    $(".modify").click(function(){
        var url = "{:url('modifyJren')}";
        var id = $(this).attr("index");
        var teacase = $(this).parents('tr').find("select[name=chooseteacase]").val();
        var teaarea = $(this).parents('tr').find("select[name=chooseteaarea]").val();
        var name= $(this).parents('tr').find("input[name=name]").val();
        var score =$(this).parents('tr').find("input[name=score]").val();
        var contact =$(this).parents('tr').find("input[name=contact]").val();
        var phone =$(this).parents('tr').find("input[name=phone]").val();
        var wechat =$(this).parents('tr').find("input[name=wechat]").val();
        var briefintro =$(this).parents('tr').find("textarea[name=briefintro]").val();
        var detailintro =$(this).parents('tr').find("textarea[name=detailintro]").val();
        var data = {
            id:id,
            teacase:teacase,
            teaarea:teaarea,
            name:name,
            score:score,
            contact:contact,
            phone:phone,
            wechat:wechat,
            briefintro:briefintro,
            detailintro:detailintro
        }

        $.post(url,data,function(data){
            if(data == 1){
                alert('修改成功');
            }
        })
    })

    //隐藏
    $("#inlineCheckbox1").click(function(){
        var a = $("th[class=contact]").html();
        if(a == '联系人'){
            $("th[class=contact]").html('')
        }else{
            $("th[class=contact]").html('联系人')
        }
        $("input[name=contact]").toggle();

    })


    $("#inlineCheckbox2").click(function(){
        var a = $("th[class=phone]").html();
        if(a == '电话'){
            $("th[class=phone]").html('')
        }else{
            $("th[class=phone]").html('电话')
        }
        $("input[name=phone]").toggle();

    })

    $("#inlineCheckbox3").click(function(){
        var a = $("th[class=wechat]").html();
        if(a == '微信'){
            $("th[class=wechat]").html('')
        }else{
            $("th[class=wechat]").html('微信')
        }
        $("input[name=wechat]").toggle();

    })

    // phone wechat briefintro detailintro
    $("#inlineCheckbox4").click(function(){
        var a = $("th[class=briefintro]").html();
        if(a == '简介'){
            $("th[class=briefintro]").html('')
        }else{
            $("th[class=briefintro]").html('简介')
        }
        $("textarea[name=briefintro]").toggle();

    })

    $("#inlineCheckbox5").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == '详情'){
            $("th[class=detailintro]").html('')
        }else{
            $("th[class=detailintro]").html('详情')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox6").click(function(){
        var a = $("th[class=case]").html();
        if(a == '茶类'){
            $("th[class=case]").html('')
        }else{
            $("th[class=case]").html('茶类')
        }
        $("select[name=chooseteacase]").toggle();

    })
    $("#inlineCheckbox7").click(function(){
        var a = $("th[class=area]").html();
        if(a == '产地'){
            $("th[class=area]").html('')
        }else{
            $("th[class=area]").html('产地')
        }
        $("select[name=chooseteaarea]").toggle();

    })


    $("select[name=teacase] ").change(function(){
        var val = $(this).find("option:selected").attr("value");
        if(val==10000){
            var a = "<option value="+10000+">查看全部</option>";
            $("select[name=teaarea]").html(a);
            exit();
        }
        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="";
            for(index in areas){
                // console.log(areas[index]["area"])
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a

            }
            // console.log(option);

            $("select[name=teaarea]").html(option)
        })
    })


</script>

</body>
</html>